package executor;

import org.junit.Test;

public class Test3 {

    Object o = new Object();

    @Test
    public void demo() {

        Thread t = new Thread(new Runnable() {
            @Override
            public void run() {
                Thread t = Thread.currentThread();



                synchronized (o) {
                    try {
                        System.out.println(" t1 状态0 ：" + t.isInterrupted());
                        //t.interrupt();
                        t.interrupted();
                        System.out.println(" t1 状态-1 ：" + t.isInterrupted());

                        try {
                            o.wait();
                        } catch (Exception a) {
                            a.printStackTrace();
                            System.out.println(" t1 状态-10 ：" + t.isInterrupted());
                        }

                        //thredExcetpin();
                    } catch (Exception e) {
                        System.out.println(" t1 状态-10 ：" + t.isInterrupted());
                        e.printStackTrace();
                        t.interrupt();


                    }
                }
            }
        });

        t.start();
        t.interrupt();

        try {
            t.sleep(1000);
        } catch (Exception a) {
        }

        synchronized (o) {
            t.interrupt();
            System.out.println(" t1 状态1 ：" + t.isInterrupted());

            System.out.println(" t1 状态2 ：" + t.isInterrupted());
            o.notify();
        }



    }


    public void thredExcetpin() throws Exception {


        throw new InterruptedException();
    }

}
